#!/usr/bin/perl

use warnings;
use strict;

use Test::More tests => 12;

BEGIN
{
    use_ok('POE::Data::Envelope');
}

my $env = POE::Data::Envelope->new();
isa_ok($env, 'POE::Data::Envelope');
is(scalar(@{$env->data()}), 0, 'Empty Data');
is(@{$env->oob()}, 0, 'Empty OOB');
is($env->error(), 0, 'Empty Error');

like($env, qr/ARRAY/, 'Envelope is an array');
like("$env", qr/ARRAY/, 'Envelope stringifies as an array reference');

eval { $env->data({}) };
isnt($@, '', 'Attempt to store hashref in data');

my $data = ['one', 'two', 'three'];
$env->data($data);
is_deeply([@$env], [@$data], 'Dereference of envelope with data');

$env->oob([{'TESTME' => ['here', 'it', 'is']}]);

is_deeply
(
    $env->oob(), 
    [{'TESTME' => ['here', 'it', 'is']}], 
    'OOB Store and get'
);

$env->error(1);

ok($env->error(), 'Error returns true value from being set');

my $clone = $env->clone();

is_deeply
(
    $clone->oob,
    $env->oob,
    'Clone preservation of OOB',
);
